package com.study.jvm;

/**
 * @author wei.zhao
 * @description:
 * @date 2022年07月07日 15:44
 */
public class Code01_引用传递or值传递 {

    public static void main(String[] args) {
        // 复杂类型
        StringBuilder sb = new StringBuilder("哈哈哈");
        handle(sb);
        System.out.println("sb：" + sb.toString());
        // 基本类型
        int i = 10;
        handle(i);
        System.out.println("i：" + i);
        // String类型
        String s = "哈哈哈";
        handle(s);
        System.out.println("s：" + s);
        // 复杂类型指向地址修改
        Student student = new Student("小明", 20);
        handle(student);
        System.out.println("student："+student.getAge());
    }

    private static void handle(StringBuilder sb) {
        sb.append("嘿嘿嘿");
    }

    private static void handle(int i) {
        i = i + 10;
    }

    private static void handle(String str) {
        str = str + "嘿嘿嘿";
    }

    private static void handle(Student stu) {
        stu=new Student();
    }

}
